<style>
    * {
        margin:0;
        padding:0;
    }
    body{
        background-color: rgba(0,0,0,0.1);
    }
    canvas{
        display: block;
        margin: 100px auto;
    }
</style>
<body>
    <div id="container"></div>
    <script src="http://www.yanhuangxueyuan.com/threejs/build/three.min.js"></script>
    <script id="vertexShader" type="x-shader/x-vertex">
        void main() {
            gl_Position = vec4( position, 1.0 );
        }
    </script>

    <script id="fragmentShader" type="x-shader/x-fragment">

        #ifdef GL_ES
        precision mediump float;
        #endif

        uniform vec2 u_resolution;
        uniform float u_time;

        float box(in vec2 _st, in vec2 _size){
            _size = vec2(0.5) - _size*0.5;
            vec2 uv = smoothstep(_size,
                                _size+vec2(0.001),
                                _st);
            uv *= smoothstep(_size,
                            _size+vec2(0.001),
                            vec2(1.0)-_st);
            return uv.x*uv.y;
        }

        float cross(in vec2 _st, float _size){
            return  box(_st, vec2(_size,_size/4.)) +
                    box(_st, vec2(_size/4.,_size));
        }

        void main(){
            vec2 st = gl_FragCoord.xy/u_resolution.xy;
            vec3 color = vec3(0.0);

            // To move the cross we move the space
            vec2 translate = vec2(cos(u_time),sin(u_time));
            st += translate*0.35;

            // Show the coordinates of the space on the background
            color = vec3(st.x,st.y,0.0);

            // Add the shape on the foreground
            color += vec3(cross(st,0.25));

            gl_FragColor = vec4(color,1.0);
        }

    </script>
    
    <script>
        var container;
        var camera, scene, renderer;
        var uniforms;

        init();
        animate();

        function init() {
            container = document.getElementById( 'container' );

            camera = new THREE.Camera();
            camera.position.z = 1;

            scene = new THREE.Scene();

            var geometry = new THREE.PlaneBufferGeometry( 2, 2 );

            uniforms = {
                u_time: { type: "f", value: 1.0 },
                u_resolution: { type: "v2", value: new THREE.Vector2() }
            };

            var material = new THREE.ShaderMaterial( {
                uniforms: uniforms,
                vertexShader: document.getElementById( 'vertexShader' ).textContent,
                fragmentShader: document.getElementById( 'fragmentShader' ).textContent
            } );

            var mesh = new THREE.Mesh( geometry, material );
            scene.add( mesh );

            renderer = new THREE.WebGLRenderer();
            renderer.setPixelRatio( window.devicePixelRatio );

            container.appendChild( renderer.domElement );

            onWindowResize();
            window.addEventListener( 'resize', onWindowResize, false );
        }

        function onWindowResize( event ) {
            renderer.setSize( window.innerHeight/2, window.innerHeight/2 );
            uniforms.u_resolution.value.x = renderer.domElement.height/2;
            uniforms.u_resolution.value.y = renderer.domElement.height/2;
        }

        function animate() {
            requestAnimationFrame( animate );
            render();
        }

        function render() {
            uniforms.u_time.value += 0.05;
            renderer.render( scene, camera );
        }
    </script>
</body>